import csv

data_list = [['name', 'age', 'gender'], ['Tom', '18', 'male'], ['Lucy', '20', 'female']]

filename = 'temp.csv';

# 把数据写入文件中
with open(filename, 'w', newline='') as f:
  writer = csv.writer(f)
  writer.writerows(data_list)
